var express = require('express');
var router = express.Router();
var {AImodel,Shenmodel}=require("../database/AIdata");

/* GET users listing. */
router.get('/aidata',async function(req, res, next) {
  const data=await AImodel.find()
  res.send({
    data:data
  })
});

//添加数据
router.post('/aiadd',async function(req, res, next) {
  await AImodel.create(req.body)
  res.send({
    code:200,
  })
  console.log(req.body);
  
});

//删除数据
router.delete('/aidelete',async function(req, res, next) {
  const id=req.params.id
  await AImodel.findByIdAndDelete(id)
  res.send({
    code:200,
    message:"删除成功"
  })
});

module.exports = router;